package com.qww.exec02;

class Cleanser {
    private String s = "Cleanser";

    public void append(String a) { s += a; }
    public Cleanser dilute() { append(" dilute()");  return this; }
    public Cleanser apply() { append(" apply()");  return this; }
    public Cleanser scrub() { append(" scrub()");  return this; }
    public String toString() { return s; }

    public static void main(String[] args) {
        Cleanser x = new Cleanser();
        x.dilute().apply().scrub();
        System.out.println(x);
    }
}

public class Detergent extends Cleanser {
    public Detergent scrub() {
        append(" Detergent.scrub()");
        super.scrub();
        return this;
    }
    public Detergent foam() { append(" foam()"); return this; }
    public static void main(String[] args) {
        Detergent x = new Detergent();
        x.foam().dilute().apply().scrub();
        System.out.println(x);
        System.out.println("Testing base class: ");
        Cleanser.main(args);
    }
}
